1. Field of the Invention
This invention relates to context scheduling in general, and more particularly to processor scheduling in a virtual machine environment.
2. Description of the Related Art
As is well known in the field of computer science, a virtual machine (VM) is an abstraction—a “virtualization”—of an actual physical computer system. The advantages of virtual machine technology have become widely recognized. Among these advantages is the ability to run multiple virtual machines on a single host platform. This makes better use of the capacity of the hardware, while still ensuring that each user enjoys the features of a “complete” computer. Depending on how it is implemented, virtualization can also provide greater security, since the virtualization can isolate potentially unstable or unsafe software so that it cannot adversely affect the hardware state or system files required for running the physical (as opposed to virtual) hardware.
A virtual machine or “guest” is installed on a “host platform,” or simply “host,” which includes system hardware and one or more layers or co-resident components comprising system-level software, such as an operating system or similar kernel, or a virtual machine monitor or hypervisor, or some combination of these. Each VM will typically have both virtual system hardware and guest system software. A single VM may be configured with more than one virtualized processor. To permit computer systems to scale to larger numbers of concurrent threads, systems with multiple processors have been developed. These symmetric multi-processor (SMP) systems are available as extensions of the personal computer platform. Essentially, an SMP system is a hardware platform that connects multiple processors to a shared main memory and shared input/output devices. Virtual machines may also be configured as SMP VMs.
In the field of processor scheduling, the ability to simultaneously schedule multiple “contexts” (e.g., virtual processors) is commonly referred to as “coscheduling” or “gang scheduling.” There are a number of reasons why coscheduling is beneficial. For instance, coscheduling is generally used to ensure that when multiple, cooperating contexts need to communicate or synchronize with each other, then they will all be ready to do so at the same time. When the contexts are virtual processors associated with a virtual machine, coscheduling is also desirable to maintain the illusion presented to the guest operating system that it is running on a dedicated physical multiprocessor. Synchronous execution may improve performance significantly, and may even be required for correctness in some cases where inter-processor operations are expected to complete quickly.
However, strict coscheduling can cause fragmentation, with the result that some physical processors may remain idle or may be underutilized even when the overall demand for processor time is high. For example, consider the problem of scheduling two CPU-bound virtual machines on a physical machine with two processors: VM1, a uniprocessor VM with a single virtual processor, and VM2, an SMP VM with two virtual processors that must be coscheduled. When VM1 is scheduled, VM2 cannot run because both of its virtual processors must be coscheduled but only one physical processor is available. As a result, even though the second physical processor is available, it will remain idle, even though there is a VM ready to run (e.g., VM2). Thus, the computer system's resources are not efficiently utilized, reducing overall performance.